package com.aolong.archives.common.util;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;

import com.rock.platform.exception.BaseException;

public class XmlUtil
{
    /**
     * 禁止实例化
     */
    private XmlUtil()
    {
    }

        /**
     * 从xml串构造Document对象
     * 
     * @param strXml
     * @return
     */
    public static Document getDocument(String strXml)
    {
        Document document = null;

        if (strXml.length() == 0)
        {
            throw new BaseException("xml串为空，无法构建实体对象！");
        }
        try
        {
            document = DocumentHelper.parseText(strXml);
        }
        catch (DocumentException e)
        {
            throw new BaseException("xml格式不正确：" + e.getMessage());
        }
        return document;

    }

}
